package com.uzai.console.web.dy;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.dy.dytoken.DyTokenIdDto;
import com.uzai.console.dto.dy.dytoken.DyTokenInfoDto;
import com.uzai.console.dto.dy.dytoken.DyTokenQuery;
import com.uzai.console.dto.locallive.tlbtoken.TlbTokenIdDto;
import com.uzai.console.dto.locallive.tlbtoken.TlbTokenInfoDto;
import com.uzai.console.dto.locallive.tlbtoken.TlbTokenQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.dy.DyTokenService;
import com.uzai.console.service.locallive.TlbTokenService;
import com.uzai.console.vo.dy.dytoken.DyTokenAuthUrlVo;
import com.uzai.console.vo.dy.dytoken.DyTokenInfoVo;
import com.uzai.console.vo.locallive.tlbtoken.TlbTokenInfoVo;
import com.uzai.console.vo.tb.tbtoken.TbTokenAuthUrlVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 抖音联盟
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "抖音联盟",tags = "抖音|抖音联盟")
@ApiSort(10)
@RestController
public class DyTokenController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(DyTokenController.class);

    @Autowired
    private DyTokenService dyTokenService;
    @Autowired
    private TlbTokenService tlbTokenService;

    @ApiOperation(value = "分页查询抖音联盟列表", notes = "分页查询抖音联盟列表", response = DyTokenInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/dyToken/findDyTokenList")
    public Object findDyTokenList(@RequestBody DyTokenQuery dyTokenQuery){
        return dyTokenService.findDyTokenList(dyTokenQuery);
    }

    @ApiOperation(value = "查询抖音联盟详情", notes = "查询抖音联盟详情", response = DyTokenInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/dyToken/findDyTokenInfo")
    public Object findDyTokenInfo(@RequestBody DyTokenIdDto dyTokenIdDto){
        return dyTokenService.findDyTokenInfo(dyTokenIdDto);
    }

    @SystemLogType(model = SystemModelEnum.DyToken, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加抖音穿山甲联盟", notes = "添加抖音穿山甲联盟")
    @ApiOperationSupport(order = 3)
    @PostMapping("/dyToken/addToken")
    public Object addDyToken(@RequestBody DyTokenInfoDto dyTokenInfoDto){
        dyTokenService.addDyToken(dyTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DyToken, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改抖音穿山甲联盟", notes = "修改抖音穿山甲联盟")
    @ApiOperationSupport(order = 4)
    @PostMapping("/dyToken/updateToken")
    public Object updateDyToken(@RequestBody DyTokenInfoDto dyTokenInfoDto){
        dyTokenService.updateDyToken(dyTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DyToken, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除抖音联盟", notes = "删除抖音联盟")
    @ApiOperationSupport(order = 5)
    @PostMapping("/dyToken/deleteToken")
    public Object deleteToken(@RequestBody DyTokenIdDto dyTokenInfoDto){
        dyTokenService.deleteToken(dyTokenInfoDto);
        return true;
    }

    @ApiOperation(value = "查询所有抖音联盟列表", notes = "查询所有抖音联盟列表", response = DyTokenInfoVo.class)
    @ApiOperationSupport(order = 11)
    @PostMapping("/dyToken/findDyTokenListSelect")
    public Object findDyTokenListSelect(@RequestBody DyTokenQuery dyTokenQuery){
        return dyTokenService.findDyTokenListSelect(dyTokenQuery);
    }

    @ApiOperation(value = "分页查询推老板抖音列表", notes = "分页查询推老板抖音列表", response = TlbTokenInfoVo.class)
    @ApiOperationSupport(order = 7)
    @PostMapping("/dyToken/findTlbTokenList")
    public Object findTlbTokenList(@RequestBody TlbTokenQuery tlbTokenQuery){
        if(StringUtils.isBlank(tlbTokenQuery.getType())){
            tlbTokenQuery.setType("dy");
        }
        return tlbTokenService.findTlbTokenList(tlbTokenQuery);
    }

    @ApiOperation(value = "分页查询推老板抖音详情", notes = "分页查询推老板抖音详情", response = TlbTokenInfoVo.class)
    @PostMapping("/dyToken/findTlbTokenInfo")
    public Object findTlbToken(@RequestBody TlbTokenIdDto tlbTokenIdDto){
        return tlbTokenService.findTlbTokenInfo(tlbTokenIdDto);
    }

    @SystemLogType(model = SystemModelEnum.TlbToken, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加推老板抖音账号", notes = "添加推老板抖音账号")
    @ApiOperationSupport(order = 8)
    @PostMapping("/dyToken/addTlbToken")
    public Object addTlbToken(@RequestBody TlbTokenInfoDto tlbTokenInfoDto){
        if(StringUtils.isBlank(tlbTokenInfoDto.getType())){
            tlbTokenInfoDto.setType("dy");
        }
        tlbTokenService.addTlbToken(tlbTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TlbToken, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改推老板抖音账号", notes = "修改推老板抖音账号")
    @ApiOperationSupport(order = 9)
    @PostMapping("/dyToken/updateTlbToken")
    public Object updateTlbToken(@RequestBody TlbTokenInfoDto tlbTokenInfoDto){
        tlbTokenService.updateTlbToken(tlbTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TlbToken, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除推老板抖音账户", notes = "删除推老板抖音账户")
    @ApiOperationSupport(order = 10)
    @PostMapping("/dyToken/deleteTlbToken")
    public Object deleteTlbToken(@RequestBody TlbTokenIdDto tlbTokenIdDto){
        if(StringUtils.isBlank(tlbTokenIdDto.getType())){
            tlbTokenIdDto.setType("dy");
        }
        tlbTokenService.deleteTlbToken(tlbTokenIdDto);
        return true;
    }

    @ApiOperation(value = "查询所有共享推老板抖音列表", notes = "查询所有共享推老板抖音列表", response = TlbTokenInfoVo.class)
    @ApiOperationSupport(order = 12)
    @PostMapping("/dyToken/findTlbDyTokenListSelect")
    public Object findTlbDyTokenListSelect(@RequestBody TlbTokenQuery tlbTokenQuery){
        if(StringUtils.isBlank(tlbTokenQuery.getType())){
            tlbTokenQuery.setType("dy");
        }
        return tlbTokenService.findTlbTokenListSelect(tlbTokenQuery);
    }

    @SystemLogType(model = SystemModelEnum.TbToken, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加抖客账号(新)", notes = "添加抖客账号(新)", response = DyTokenAuthUrlVo.class)
    @ApiOperationSupport(order = 13)
    @PostMapping("/dyToken/addDyTokenAuth")
    public Object addDyTokenAuth(){
        return dyTokenService.addDyTokenAuth(getLoginInfo().getMerId());
    }

    @SystemLogType(model = SystemModelEnum.DyToken, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改抖客账号(新)", notes = "修改抖客账号(新)")
    @ApiOperationSupport(order = 14)
    @PostMapping("/dyToken/updateDyTokenAuth")
    public Object updateDyTokenAuth(@RequestBody DyTokenInfoDto dyTokenInfoDto){
        dyTokenService.updateDyTokenAuth(dyTokenInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DyToken, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除抖客账号(新)", notes = "删除抖客账号(新)")
    @ApiOperationSupport(order = 5)
    @PostMapping("/dyToken/deleteDyTokenAuth")
    public Object deleteDyTokenAuth(@RequestBody DyTokenIdDto dyTokenInfoDto){
        dyTokenService.deleteDyTokenAuth(dyTokenInfoDto);
        return true;
    }

}
